window.onload = function () {
    var regtel = /^1[3|4|5|7|8|9]\d{9}$/; //手机号的正则表达式
    var regmsg = /^\d{6}$/; //短信验证表达式
    var regpsw = /^[a-zA-Z0-9_-]{6,16}$/; //密码验证表达式
    var tel = document.querySelector('#tel');
    var msg = document.querySelector('#msg');
    var psw = document.querySelector('#psw');
    var surepsw = document.querySelector('#surepsw');
    regexp(tel, regtel);
    regexp(msg, regmsg);
    regexp(psw, regpsw);

    function regexp(ele, reg) {
        ele.onblur = function () {
            if (reg.test(this.value)) {
                console.log('正确的');
                this.nextElementSibling.className = 'success';
                this.nextElementSibling.innerHTML = '<i class="success_icon"></i>恭喜您输入正确</span>';
            } else {
                console.log('不正确的');
                this.nextElementSibling.className = 'error';
                this.nextElementSibling.innerHTML = '<i class="error_icon"></i>格式不正确,请重新输入</span>';
            }

        }
    }
    surepsw.onblur = function () {
        if (this.value == psw.value) {
            this.nextElementSibling.className = 'success';
            this.nextElementSibling.innerHTML = '<i class="success_icon"></i>恭喜您输入正确</span>';
        } else {
            this.nextElementSibling.className = 'error';
            this.nextElementSibling.innerHTML = '<i class="error_icon"></i>两次密码输入不一致,请重新输入</span>';
        }

    }
}